
const Order = require('../model/order.model.js')

class OrderService {
 async createOrder(order) {
  return await Order.create(order)
 }
 async findAllOrder(pageNum, pageSize, status) {
  const { count, rows } = await Order.findAndCountAll({
   where: { status },
   offset: (pageNum - 1) * pageSize,
   limit: pageSize,
   attributes: ['goods_info', 'total', 'order_number', 'status']
  })
  return {
   pageNum, pageSize, total: count, list: rows
  }
 }
 async updateOrder(id, status) {
  return await Order.update({ status }, { where: { id } })
 }
}

module.exports = new OrderService()